home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1888 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.9 KB

  1. Path: galaxy.ucr.edu!not-for-mail
  2. From: thp@cs.ucr.edu (Tom Payne)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Multithreading in C++?
  5. Date: 13 Jan 1996 21:16:28 GMT
  6. Organization: University of California, Riverside Department of Computer Science
  7. Message-ID: <4d97fc$ps6@galaxy.ucr.edu>
  8. References: <4co6mf$98d@serv.hinet.net> <4cta8m$i74@isoit109.bbn.hp.com>
  9. NNTP-Posting-Host: corvette.ucr.edu
  10. X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
  11.  
  12. Manfred_Lange (Manfred_Lange@bbn.hp.com) wrote:
  13. : jcwang@hntp2.hinet.net (John C. Wang) wrote:
  14. : >
  15. : >Does anyone know if there is a standard C interface for multithread
  16. : >programming? Under MS Visual C++ there are thread functions for the NT, but I
  17. : >am pretty sure that's not a standard function call. What do they use in UNIX?
  18. : >Does the POSIX standards specify this?
  19. : >
  20. : >Please reply to my email if possible.
  21. : >
  22. : >jcwang@csie.ntu.edu.tw
  23. : >
  24. : As far as I know, there are no functions in the standard libraries that deal 
  25. : with threads. This is typically left to the underlying operating system.
  26.  
  27. Not only do the C and C++ standards not support multithreading, they
  28. sort of discourage it, e.g., by specifying that the behavior of a
  29. program is "undefined" if a signal handler reads any static variable.
  30. There are, however, some standard threads packages, e.g. Pthreads that
  31. have been ported to many systems.  
  32.  
  33. On most systems one can (nonportably) implement threads by passing the
  34. control with setjmp and longjmp.  Such packages are officially
  35. non-portable, but they work on most systems.  Porting them usually
  36. requires nothing more than determining how to initialize a jmp_buf
  37. with a new stack-pointer setting.  (As I recall, John English had an
  38. article in SIGPLAN Notices about a year ago on such a package.)  There
  39. is serious question whether such packages work in the presence of
  40. exceptions.
  41.  
  42. In any case, the lack of libraries that are safe in the presence of
  43. multi-threading remains a problem.
  44.  
  45. Tom Payne (thp@cs.ucr.edu)
  46.  
  47.